package net.uiiang.android.alkaid;

import java.util.ArrayList;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.widget.TabHost;

public class BrowseFileTab extends TabActivity {
    static TabHost tabHost;
    static TabHost.TabSpec tabRoot;
    static TabHost.TabSpec tabSdCard;
    static TabHost.TabSpec tabFavorite;
    public static ArrayList<String> favoritePathList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tabHost = getTabHost();

//        System.out.println("in BrowseFileTab ");
//        FileManagerDbAdapter fileManagerDbAdapter = new FileManagerDbAdapter(this);
//        fileManagerDbAdapter.open();
//        Cursor c = fileManagerDbAdapter.fetchAllFavorite();
//        favoritePathList = FavoriteUtil.convertCursorToPathList(c);
//        fileManagerDbAdapter.close();
////        favoritePathList = FileManagerDbAdapter.favoritePathList;
//        System.out.println("in BrowseFileTab favorite = "+favoritePathList.size());

        tabFavorite = tabHost.newTabSpec("tab3").setIndicator(
                getResources().getString(R.string.favorite),
                getResources().getDrawable(android.R.drawable.btn_star_big_on))
                .setContent(new Intent(this, FavoriteList.class));
        tabHost.addTab(tabFavorite);
        
        Intent intent = getBrowseDefaultRootIntent();
        tabRoot = tabHost.newTabSpec("tab1").setIndicator(
        // getResources().getString(R.string.tab_phone),
                "", getResources().getDrawable(R.drawable.ic_launcher_android))
                .setContent(intent);
        tabHost.addTab(tabRoot);
        
        intent = getBrowseDefualtSdCardIntent();
        tabSdCard = tabHost.newTabSpec("tab2").setIndicator(
        // getResources().getString(R.string.tab_sdcard),
                "", getResources().getDrawable(R.drawable.sdcard)).setContent(
                intent);
        tabHost.addTab(tabSdCard);
        
//        tabHost.setCurrentTab(2);
    }
    
    public static Intent getBrowseDefaultRootIntent(){
        Intent intent = new Intent("net.uiiang.android.alkaid.FILEMANAGER");
        intent.putExtra(Constant.THIRD_PARTY_CALL, false);
        intent.putExtra("root_directory", "/");
        intent.putExtra("exclude_directory", new String[] { Environment
                .getExternalStorageDirectory().getAbsolutePath() });
        intent.putExtra(Constant.USE_SIMPLE_VIEW, true);
        return intent;
    }
    
    public static Intent getBrowseDefualtSdCardIntent(){
        Intent intent = new Intent("net.uiiang.android.alkaid.FILEMANAGER");
        intent.putExtra(Constant.THIRD_PARTY_CALL, false);
        intent.putExtra(Constant.USE_SIMPLE_VIEW, true);
        intent.putExtra("root_directory", Environment
                .getExternalStorageDirectory().getAbsolutePath());
        return intent;
    }
}
